package com.thwj.project.app.api;

import com.thwj.framework.web.domain.R;
import com.thwj.project.amap.dto.AppLocationDTO;
import com.thwj.project.app.service.AppAreaService;
import com.thwj.project.app.service.AppAssociationService;
import com.thwj.project.biz.domain.Association;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@Api(tags="app 社群相关接口")
@RestController
@RequestMapping("/app/association")
public class AppAssociationController {


    @Autowired
    private AppAssociationService appAssociationService;
    @Autowired
    private AppAreaService appAreaService;

    @ApiOperation(value = "获取当前条件下的社群二维码",notes = "优先匹配用户当前城市，如果有当前城市默认选中")
    @GetMapping("/getAssociationList")
    public R<List<Association>> getAssociationList() {
        AppLocationDTO appLocationDTO = appAreaService.getAppLocationVo(false);
        log.info("根据经纬度获取地址信息：{}", appLocationDTO);
        List<Association> associationList = appAssociationService.getAssociationList(appLocationDTO);
        return R.data(associationList);
    }
}
